/**
*      author: Y_Yao
*      created: 2025-04-11 21:17:15
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
int a[101];
int getmonthday[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

void solve()
{
    for(int i = 1;i <= 100;i++)
    {
        cin >> a[i];
    }

    int ans = 0;
    for(int m = 1;m <= 12;m++)
    {
        int allday = getmonthday[m];
        for(int d = 1;d <= allday;d++)
        {
            int date[] = {2,0,2,3,m / 10,m % 10,d / 10,d % 10};
            int cnt = 0;
            for(int i = 1;i <= 100;i++)
            {
                if(a[i] == date[cnt]) cnt++;
                if(cnt == 8)
                {
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}